#!/usr/bin/env python
# -*- coding: UTF-8 -*-
'''
@Project ：图灵学习 
@File    ：5.操作系统.py
@IDE     ：PyCharm 
@Author  ：ChenLiGao
@Date    ：2024-11-18 09:57
'''
import pymongo

# with pymongo.MongoClient() as mongo_client:
#     db = mongo_client["stu_info"]["stu_test"]
#     stu_list = [
#         {"name":"双双", "age":20},
#         {"name":"南风", "age":21},
#         {"name":"夏洛", "age":22},
#     ]
#     db.insert_many(stu_list)
#
#     results = db.find({"age":20})
#     print(results)
#     for  result in results:
#         print(result)

mongo_client = pymongo.MongoClient()
db = mongo_client["stu_info"]["stu_test"]
stu_list = [
    {"name":"双双", "age":20},
    {"name":"南风", "age":21},
    {"name":"夏洛", "age":22},
]
db.insert_many(stu_list)

results = db.find({"age":20})
print(results)
for  result in results:
    print(result)

mongo_client.close()